package com.zt.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.validation.constraints.*;
import lombok.Data;


import java.math.BigDecimal;
import java.util.Date;

/**
 * 创建优惠券请求DTO
 */
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class CouponCreateRequest {

    @NotBlank(message = "优惠券标题不能为空")
    @Size(max = 100, message = "优惠券标题长度不能超过100个字符")
    private String title;

    @Size(max = 500, message = "优惠券描述长度不能超过500个字符")
    private String description;

    @NotNull(message = "优惠券类型不能为空")
    @Min(value = 1, message = "优惠券类型值无效")
    @Max(value = 3, message = "优惠券类型值无效")
    private Integer type;

    @NotNull(message = "优惠券金额不能为空")
    @DecimalMin(value = "0.01", message = "优惠券金额必须大于0")
    @DecimalMax(value = "9999.99", message = "优惠券金额不能超过9999.99")
    private BigDecimal amount;

    @DecimalMin(value = "0.00", message = "最低消费金额不能为负数")
    @DecimalMax(value = "99999.99", message = "最低消费金额不能超过99999.99")
    private BigDecimal minSpend;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    @Min(value = 1, message = "发放数量必须大于0")
    @Max(value = 10000, message = "发放数量不能超过10000")
    private Integer totalCount;

    @Min(value = 1, message = "每人限领数量必须大于0")
    @Max(value = 100, message = "每人限领数量不能超过100")
    private Integer limitPerUser;

    /**
     * 生效时长（小时）
     */
    @Min(value = 1, message = "生效时长必须大于0小时")
    @Max(value = 8760, message = "生效时长不能超过8760小时（1年）")
    private Integer validHours;
}
